#include<iostream>

template <class Data, unsigned int Capacity>
class Queue
{
private:
	Data values[Capacity];
	unsigned int start;
	unsigned int _size;
public:
	Queue(){start = 0; _size = 0;}

	bool push (const Data& value);
	bool pop (Data& outValue);

	unsigned int size()const
		{return _size;}
	bool isEmpty()const 
		{return _size == 0;}
};

template <class Data, unsigned int Capacity>
bool Queue<Data,Capacity>::push (const Data& value)
{
	if (_size >= Capacity)
	{
		return false;
	}
	if (start + _size < Capacity)
	{
		values[start + _size] = value;
	}
	else
	{
		values[start + _size - Capacity] = value;
	}
	_size++;
	return true;
}

template <class Data, unsigned int Capacity>
bool Queue<Data, Capacity>::pop (Data& outValue)
{
	if (isEmpty())
	{
		return false;
	}
	outValue = values[start];
	start++;
	if (start == Capacity)
	{
		start = 0;
	}
	_size--;
	return true;
}